package com.zmn.oms.common.constant;

import com.google.common.collect.Lists;

import java.util.*;

/**
 * 渠道-工单照片类型枚举
 *
 * @author linfeng
 * @since 2020/09/16 14:47:16
 */
public enum OrderAttachmentTypeEnum {

    /**
     * values
     */
    AZHJ(1, "安装环境照片"),
    WXHJ(10, "维修环境照片"),
    JQTXM(2, "机器条形码"),
    ZJTSZ(3, "整机调试照"),
    FHWL(4, "返还物流照片"),
    XJ(5, "新旧照片"),
    GZ(6, "故障照片"),
    HP(7, "好评照"),
    XJCJ(8, "新机拆机照"),
    QRS(9, "确认书"),
    MPZ(11, "名牌照"),
    SGQ(12, "施工前照片"),
    WGH(13, "完工后照片"),
    XXZ(14, "形象照"),
    ZBZ(15, "装备照"),
    THZ(16, "贴花照"),

    YBJD(17, "预报价单"),
    SJTZ(18, "设计图纸"),
    ZCQD(19, "主材清单"),
    QTZP(141, "其他照片"),
    SGHT(110, "施工合同"),
    JCGDZP(111, "进场工单照片"),
    SDGZGDZP(112, "水电改造工单照片"),
    SDYSD(113, "水电验收单"),
    FSGDZP(114, "防水工单照片"),
    FSYSD(115, "防水验收单"),
    TZGDZ(116, "贴砖工单照片"),
    TZYSD(117, "贴砖验收单"),
    SWGDZ(118, "收尾工单照片"),
    SWYSZ(119, "收尾验收单"),
    JGGDZ(120, "竣工工单照片"),
    JGYSD(121, "竣工验收单"),
    JPJZP(123, "旧配件照片"),
    XPJZP(124, "新配件照片"),
    XJZP(142, "清洁照片"),

    WXXDZ(999,"微笑行动照片"),

    VIDEO_BEFORE_REPAIR(21,"维修前"),
    VIDEO_IN_REPAIR(22,"维修中"),
    VIDEO_AFTER_REPAIR(23,"维修后"),
    BGC(168, "报告书");

    /**
     * 安装环境照片
     */
    public static final int CONSTS_AZHJ = 1;
    /**
     * 维修环境照片
     */
    public static final int CONSTS_WXHJ = 10;
    /**
     * 机器条形码
     */
    public static final int CONSTS_JQTXM = 2;
    /**
     * 整机调试照
     */
    public static final int CONSTS_ZJTSZ = 3;
    /**
     * 返还物流照片
     */
    public static final int CONSTS_FHWL = 4;
    /**
     * 新旧照片
     */
    public static final int CONSTS_XJ = 5;
    /**
     * 故障照片
     */
    public static final int CONSTS_GZ = 6;
    /**
     * 好评照
     */
    public static final int CONSTS_HP = 7;
    /**
     * 新机拆机照
     */
    public static final int CONSTS_XJCJ = 8;
    /**
     * 确认书
     */
    public static final int CONSTS_QRS = 9;
    /**
     * 名牌照
     */
    public static final int CONSTS_MPZ = 11;
    /**
     * 施工前照片
     */
    public static final int CONSTS_SGQ = 12;
    /**
     * 完工后照片
     */
    public static final int CONSTS_WGH = 13;
    /**
     * 形象照
     */
    public static final int CONSTS_XXZ = 14;
    /**
     * 装备照片
     */
    public static final int CONSTS_ZBZ = 15;
    /**
     * 贴花照
     */
    public static final int CONSTS_THZ = 16;
    /**
     * 其他照片
     */
    public static final int CONSTS_QTZP = 141;
    /**
     * 旧配件照片
     */
    public static final int CONSTS_JPJZP = 123;
    /**
     * 新配件照片
     */
    public static final int CONSTS_XPJZP = 124;
    /**
     * 清洁照片
     */
    public static final int CONSTS_QJZP = 142;

    private Integer code;
    private String name;

    OrderAttachmentTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    // 需要自动审核的列表
    public static final List<Integer> CODE_LIST = Lists.newArrayList(
            AZHJ.code,
            WXHJ.code,
            JQTXM.code,
            ZJTSZ.code,
            FHWL.code,
            XJ.code,
            GZ.code,
            HP.code,
            XJCJ.code,
            QRS.code,
            MPZ.code,
            SGQ.code,
            WGH.code,
            XXZ.code,
            ZBZ.code,
            THZ.code
    );


    // 需要过滤掉的照片类型
    public static final List<Integer> FILTER_PICTURE_LIST = Lists.newArrayList(
            THZ.code,
            QTZP.code
    );

    /**
     * 有特殊业务规则的照片类型
     */
    public static final List<Integer> SPECIAL_RULE_PICTURE_LIST = Lists.newArrayList(
            ZBZ.code
    );

    public static final List<OrderAttachmentTypeEnum> ENUM_LIST = Lists.newArrayList();
    private static final Map<Integer, OrderAttachmentTypeEnum> orderAttachmentTypeEnumMap = new HashMap<>();

    static {
        for (OrderAttachmentTypeEnum orderAttachmentTypeEnum : EnumSet.allOf(OrderAttachmentTypeEnum.class)) {
            orderAttachmentTypeEnumMap.put(orderAttachmentTypeEnum.getCode(), orderAttachmentTypeEnum);
            ENUM_LIST.add(orderAttachmentTypeEnum);
        }
    }

    public static OrderAttachmentTypeEnum of(Integer code) {
        if (code == null) {
            return null;
        }
        return orderAttachmentTypeEnumMap.get(code);
    }

    public static String getName(Integer code) {
        OrderAttachmentTypeEnum of = of(code);
        return of == null ? null : of.getName();
    }

    public static OrderAttachmentTypeEnum[] list() {
        return ENUM_LIST.toArray(new OrderAttachmentTypeEnum[ENUM_LIST.size()]);
    }
}
